package com.core.gig.util;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import org.apache.commons.beanutils.BeanUtils;

/**
 * 
 * @author Lucas Ceni
 *
 */
public class GIGUtil
{
	private static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
	private static NumberFormat df = DecimalFormat.getInstance(new Locale("pt", "BR"));
	
	public static final void copyProperties(Object dest, Object origin)
	{
			try
			{
				BeanUtils.copyProperties(dest, origin);
			}
			catch (Exception e)
			{
				e.printStackTrace();
			}
	}
	
	public static final String formatDate(Date date)
	{
		return sdf.format(date);
	}
	
	public static final String formatNumber(Double number)
	{
		df.setMinimumFractionDigits(2);
		df.setMaximumFractionDigits(2);
		df.setGroupingUsed(false);
		return df.format(number);
	}
	
	public static String getArea(String area)
	{
		return AreaEnum.valueOf(area).toString();
	}
	
	public static String getCalculo(String calculo)
	{
		return CalculoHoraEnum.valueOf(calculo).toString();
	}
	
	public static String getTributacao(String tributacao)
	{
		return TributacaoEnum.valueOf(tributacao).toString();
	}
}